{extend name="public:base" /}
{block name="content"}
<link rel="stylesheet" href="__CSS__/addcomon.css">
<div class="row" style="padding:15px;">
    <div class="col-xs-12">
        <form id="commentForm" action="{:url('rwlx_edit')}" method="post">
            <div class="box">
            <div class="box-header" data-original-title="" style="height: 40px;">
                <h2><i class="glyphicon glyphicon-plus"></i>编辑任务类型</h2>
            </div>
            <div class="add-box">
                <div class="box-left">
                    <input type="hidden" name="id"  value="{$info.id}">
                    <div class="form-group">
                        <label>类型名称:</label>
                        <input type="text" name="name"  required class="form-control" value="{$info.name}">
                    </div>
                    <div class="form-group">
                        <label>是否启用:</label>
                        <input name="status" value="1" type="checkbox" {eq name="info.status" value='1'}checked{/eq} />
                    </div>
                </div>
                <div class="btn-box">
                    <button type="submit" class="btn btn-color-o" id="submit">确定</button>
                    <button type="reset" class="btn btn-color-g">重置</button>
                </div>
            </div>
        </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript" src="__STATIC__/validate/jquery.validate.min.js"></script>
<script>
    $().ready(function() {
        // 在键盘按下并释放及提交后验证提交表单
        $("#commentForm").validate({
            submitHandler: function(form)
            {
                $.ajax({
                    type: "POST",
                    url:  "{:url('rwlx_edit')}",
                    data: $(form).serialize(),
                    beforeSend:function(){
                        $('#submit').attr("disabled","false"); //禁止点击
                    },
                    success: function(msg){
//                        console.log(msg);
                        if(msg.status==1){
                            $('#submit').attr("disabled","false"); //禁止点击
                            layer.msg(msg.info, {icon: 1});
                            setTimeout(function(){
                                location.href=msg.url;
                            },3000); //延迟演示
                        }else{
                            layer.msg(msg.info, {icon: 2});
                            $('#submit').removeAttr("disabled"); //禁止点击
                        }

                    }
                });
            }

        });
        return false;
    });
    highlight_subnav("{:url('renwuleixing')}");
</script>
{/block}